/**
 * FileFind - ftp/shares indexing and search php engine
 * Module: agent-java
 * Description: Agent written in java language
 * Copyright (c) 2003-2010 Rage Steel, www.gt2.ru
 * ----------------------------------------------
 * $Id$
 */
package ru.ffind.agent.db;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 *
 * Database tools
 *
 * @author Rage Steel
 *
 */
public class DbTools {
	
	private DbTools() {
        // Private constuctor to disallow creating of instance
	}

	public static Long getRsLong(ResultSet rs, String columnLabel) throws SQLException {
		Long result = rs.getLong(columnLabel);
		return (0 != result) ? result : (rs.wasNull() ? null : result);
	}

	public static Integer getRsInteger(ResultSet rs, String columnLabel) throws SQLException {
		Integer result = rs.getInt(columnLabel);
		return (0 != result) ? result : (rs.wasNull() ? null : result);
	}
	
	public static Short getRsShort(ResultSet rs, String columnLabel) throws SQLException {
		Short result = rs.getShort(columnLabel);
		return (0 != result) ? result : (rs.wasNull() ? null : result);
	}

	public static Byte getRsByte(ResultSet rs, String columnLabel) throws SQLException {
		Byte result = rs.getByte(columnLabel);
		return (0 != result) ? result : (rs.wasNull() ? null : result);
	}
	
}
